<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('用户表');
            $table->string('user_nu')->unique()->comment('用户编号');
            $table->string('username')->unique()->comment('登录账户');
            $table->string('email')->unique()->comment('邮箱');
            $table->string('nick_name')->nullable()->comment('用户id');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('password')->comment('密码');
            $table->string('phone')->nullable()->comment('手机号码');
            $table->enum('role', ['customer', 'seller'])->default('customer')->comment('角色 customer:顾客,seller:商家');
            $table->enum('login_status', ['forbidden', 'normal'])->default(\App\Models\User::NORMAL)->comment('登录状态');
            $table->enum('gag_status', ['forbidden', 'normal'])->default(\App\Models\User::NORMAL)->comment('禁言状态');
            $table->string('gag_duration')->nullable()->comment('禁言时长');
            $table->timestamps();
        });

        Schema::create('user_data', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('用户详情表');
            $table->integer('user_id')->comment('用户id');
            $table->tinyInteger('age')->default(0)->comment('年龄');
            $table->double('stature', 5, 2)->default(0)->comment('身高');
            $table->double('weight', 5, 2)->default(0)->comment('体重');
            $table->double('bust', 5, 2)->default(0)->comment('胸围');
            $table->double('waist', 5, 2)->default(0)->comment('腰围');
            $table->double('hips', 5, 2)->default(0)->comment('臀围');
            $table->string('video_cover')->nullable()->comment('视频封面');
            $table->string('video')->nullable()->comment('视频地址');
            $table->text('intro')->nullable()->comment('介绍');
            $table->timestamps();

        });

        Schema::create('wallets', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('钱包表');
            $table->integer('user_id')->comment('用户id');
            $table->decimal('balance', 10, 2)->default('0.000')->comment('余额');
            $table->string('alipay_account')->unique()->nullable()->comment('支付宝账号');
            $table->string('true_name')->nullable()->comment('真实姓名');
            $table->string('bank_account')->unique()->nullable()->comment('银行卡账号');
            $table->string('bank')->nullable()->comment('开户行');
            $table->string('pay_password')->nullable()->comment('支付密码');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
        Schema::dropIfExists('user_data');
        Schema::dropIfExists('wallets');
    }
}
